from models.meta import BaseDocument, IdField, fields


class RetryRequests(BaseDocument):
    meta = {
        'collection': "web_retry_requests",
        'primary_key': 'request_id',
        'indexes': ['request_id', '-created_at'],
        'ordering': ['-created_at']
    }

    request_id = IdField(unique=True)
    url = fields.StringField()
    method = fields.StringField()
    headers = fields.DictField()
    body = fields.DictField()
    send_count = fields.IntField(default=0, min_value=0)
    is_ok = fields.BooleanField(default=False)
    url_id = IdField(default='')
